package com.Shop.Center.service;

import com.Shop.Center.dao.AdminUserMapper;
import com.Shop.Center.dao.UserMapper;
import com.Shop.Center.entity.AdminUser;
import com.Shop.Center.entity.User;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminUserService {
    @Autowired
    AdminUserMapper adminUserMapper;
    public int insert(String name,String password){
        AdminUser user=new AdminUser();
        int id=new IdWorker().hashCode();
        user.setId(id);
        user.setName(name);
        user.setPassword(password);
        return adminUserMapper.insert(user);
    }
    public List<AdminUser> get(String name){
        QueryWrapper<AdminUser> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("name",name);
        return adminUserMapper.selectList(queryWrapper);
    }
    public int update(String name,String age,String telephone,String address,String points,int id){
        AdminUser adminUser=new AdminUser();
        adminUser.setId(id);
        adminUser.setName(name);
        return adminUserMapper.updateById(adminUser);
    }
}
